import Layout from '@/components/layout'
import routesConfig from './routes-config'
const customRoutes = routesConfig.map(v => (
  {
    ...v,
    path: `/${v.name}`,
    component: Layout,
    children: v.children && v.children.map(value => (
      {
        ...value,
        path: `/${v.name}/${value.name}`,
        name: `${v.name}-${value.name}`,
        component: () => value.component()
      }
    ))
  }
))
/**
 * 路由集合
 */
const routes = [
  {
    path: '*',
    redirect: '/dashboard/workbench',
    hidden: true
  },
  {
    name: '403',
    path: '/403',
    component: () => import('@/views/error/403'),
    hidden: true
  },
  {
    name: 'login',
    path: '/login',
    component: () => import('@/views/user/login'),
    hidden: true
  },
  ...customRoutes
]

export default routes